package com.example.administrator.fishbone.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by ${杨文超} on 2016/9/2.
 */
public class LinkmanHelper extends SQLiteOpenHelper {
    private final static String name = "LinkMan";
    private final static int vweson = 1;

    public LinkmanHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table Linkman([_id] INTEGER PRIMARY KEY AUTOINCREMENT,[name] nvarchar(20) not null,[last] nvarchar(20))";
        //提交SQL语句
        db.execSQL(sql);
        initData(db);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
    private String[] getName() {
        String[] names = new String[]{"陈钰", "原航", "冯傲杰", "柏海鹏", "袁伟", "宗荣华", "陈改伟", "吕振亚", "徐伟杰",
                "冯少强", "刘合庞", "李长伟", "温帅", "谢倩", "付园园", "周子文", "洪传威", "郭帅良", "邹家兴",
                "马红宾", "徐凌雷", "王想", "杨洋", "赵文龙", "胡晨辉", "张磊", "孙宇峰", "王业通", "翟传凯",
                "孙永恒", "平佳桐", "崔海宽", "杨文超", "吕金鹏", "董凯", "朱双磊", "王家然", "张佳", "高寒"};
        return names;
    }
    private void initData(SQLiteDatabase db) {
        //把定义的好数据拿来放入String里
        String[] name = getName();
        for (int i = 0; i < name.length; i++) {
            //插入 数据库语句
            String sql = "INSERT INTO Linkman(name) VALUES(?)";
            db.execSQL(sql,new Object[]{name[i]});
        }
    }

}
